package com.axx.android.moments;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.axx.android.R;
import com.axx.android.utils.ImageLoader;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2017/8/3 0003.
 */

public class ImageAdapter extends BaseQuickAdapter<ImageModel,BaseViewHolder> {
    private boolean add;

    public ImageAdapter(@LayoutRes int layoutResId, @Nullable List<ImageModel> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ImageModel item) {
        if (item.isAdd()){
            helper.setImageResource(R.id.iv_image,R.drawable.ic_take_photo);
        }else{
            ImageLoader.loadImage(item.getUrl(), (ImageView) helper.getView(R.id.iv_image),mContext);
            if (item.isCanDel()){
                helper.setVisible(R.id.iv_del,true);
            }else{
                helper.setVisible(R.id.iv_del,false);
            }
        }
        helper.addOnClickListener(R.id.iv_del);
        helper.addOnClickListener(R.id.iv_image);

    }
}
